#include<bits/stdc++.h>
#define int long long
#define N 200005
using namespace std;
int k,m;
int n,q;
int l[N],r[N],x[N];
char s[N];
signed main(){
    freopen("copy.in","r",stdin);
    freopen("copy.out","w",stdout);
    scanf("%lld %lld",&k,&m);
    scanf("%s",s+1);
    n=strlen(s+1);
    scanf("%lld",&q);
    for(int i=1;i<=q;i++){
        scanf("%lld %lld %lld",&l[i],&r[i],&x[i]);
        l[i]++;
    }
    for(int i=1;i<=k;i++){
        int p=i;
        for(int j=q;j>=1;j--){
            int len=r[j]-l[j]+1,L=x[j]+1,R=x[j]+len;
            if(R<p) p-=len;
            else if(L<=p&&p<=R) p=(l[j]+(p-L));
        }
        printf("%c",s[p]);
    }
    return 0;
}